package com.haiyuancloud.create.service.impl;

import com.haiyuancloud.base.deal.core.chain.compile.service.ProductCreateCompileInitScriptService;
import com.haiyuancloud.base.deal.core.chain.compile.model.HyDealDBModel;
import com.haiyuancloud.create.properties.service.HyDealDBService;
import com.haiyuancloud.create.service.CreateScriptService;
import lombok.extern.log4j.Log4j;
import org.springframework.stereotype.Service;
import org.springframework.util.ResourceUtils;

import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.util.Map;

@Log4j
@Service("com.haiyuancloud.create.service.impl.CreateScriptServiceImpl")
public class CreateScriptServiceImpl implements CreateScriptService {

    @Resource
    private ProductCreateCompileInitScriptService productCreateInitScriptService;

    @Resource
    private HyDealDBService hyDealDBService;

    @Override
    public void create() {
        String zipFile = "D:\\work\\HaiYuanCloud\\Haiyuan-Cloud\\haiyuan-cloud-server\\haiyuan-create-server\\src\\main\\resources\\init\\createScript.zip";
        Map<String, HyDealDBModel> hyDealDBModelcache = hyDealDBService.initHyDealDBCache();
        productCreateInitScriptService.createInitData(zipFile,hyDealDBModelcache);
    }

    @Override
    public void create(String zipFile){
        Map<String, HyDealDBModel> hyDealDBModelcache = hyDealDBService.initHyDealDBCache();
        productCreateInitScriptService.createInitData(zipFile,hyDealDBModelcache);
    }
}
